/*
 * QTeXPreview
 * Copyright (C) 2008, Philip Pronin (philip.pronin@gmail.com)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "configDialog.h"
#include "settings.h"

ConfigDialog::ConfigDialog(MainWindow* parent) : QDialog(parent) {
	setupUi(this);

	Settings* settings = Settings::getInstance();
	checkBoxStayOnTop->setChecked(settings->getStayOnTop());

	int sel = 0;
	for (int i = 0; i < parent->getLangActions().count(); i++) {
		const QPair<QString, QAction*>& p = parent->getLangActions()[i];
		if (p.first == settings->getLocale()) sel = i;
		comboBoxLanguage->addItem(p.second->text().remove('&'));
	}
	comboBoxLanguage->setCurrentIndex(sel);

	checkBoxHighlight->setChecked(settings->getSyntaxHighlighting());
	checkBoxHighlightBr->setChecked(settings->getBracketsMatching());
}

bool ConfigDialog::StayOnTop() const {
	return checkBoxStayOnTop->checkState() == Qt::Checked;
}

int ConfigDialog::LanguageCode() const {
	return comboBoxLanguage->currentIndex();
}

bool ConfigDialog::Highlight() const {
	return checkBoxHighlight->checkState() == Qt::Checked;
}

bool ConfigDialog::BracketsMatching() const {
	return checkBoxHighlightBr->checkState() == Qt::Checked;
}
